<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sort array using specified collator</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.sortwithsortkeys.html">Collator::sortWithSortKeys</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.numberformatter.html">NumberFormatter</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="collator.sort" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Collator::sort</h1>
  <h1 class="refname">collator_sort</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Collator::sort</span> -- <span class="refname">collator_sort</span> &mdash; <span class="dc-title">Sort array using specified collator</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-collator.sort-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span> 
   <span class="methodname"><strong>Collator::sort</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$arr</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$sort_flag</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> 
   <span class="methodname"><strong>collator_sort</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.collator.html" class="type Collator">Collator</a></span> <code class="parameter">$coll</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$arr</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$sort_flag</code></span>
  ] )</div>

  <p class="para rdfs-comment">This function sorts an array according to current locale rules.</p>
  <p class="para">
   Equivalent to standard PHP
   <span class="function"><a href="function.sort.html" class="function">sort()</a></span> .
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-collator.sort-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">coll</code></em></dt>

     <dd>

      <p class="para">
       <a href="class.collator.html" class="classname">Collator</a> object.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">arr</code></em></dt>

     <dd>

      <p class="para">
       Array of strings to sort.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">sort_flag</code></em></dt>

     <dd>

      <p class="para">
       Optional sorting type, one of the following:
      </p>
      <p class="para">
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::SORT_REGULAR</code></strong>
          - compare items normally (don&#039;t change types)
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::SORT_NUMERIC</code></strong>
          - compare items numerically
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::SORT_STRING</code></strong>
          - compare items as strings
         </p>
        </li>
       </ul>
       Default sorting type is <strong><code>Collator::SORT_REGULAR</code></strong>.
       It is also used if an invalid <em><code class="parameter">sort_flag</code></em> value has been specified.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>



 <div class="refsect1 returnvalues" id="refsect1-collator.sort-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-collator.sort-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2436">
    <p><strong>Example #1 <span class="function"><strong>collator_sort()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$coll&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'en_US'&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$arr&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;array(&nbsp;</span><span style="color: #DD0000">'at'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'às'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'as'&nbsp;</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_export</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">collator_sort</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_export</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array (
  0 =&gt; &#039;at&#039;,
  1 =&gt; &#039;às&#039;,
  2 =&gt; &#039;as&#039;,
)array (
  0 =&gt; &#039;as&#039;,
  1 =&gt; &#039;às&#039;,
  2 =&gt; &#039;at&#039;,
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-collator.sort-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="class.collator.html#intl.collator-constants" class="link"><a href="class.collator.html" class="classname">Collator</a> constants</a></li>
    <li class="member"><span class="function"><a href="collator.asort.html" class="function" rel="rdfs-seeAlso">collator_asort()</a> - Sort array maintaining index association</span></li>
    <li class="member"><span class="function"><a href="collator.sortwithsortkeys.html" class="function" rel="rdfs-seeAlso">collator_sort_with_sort_keys()</a> - Sort array using specified collator and sort keys</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.sortwithsortkeys.html">Collator::sortWithSortKeys</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.numberformatter.html">NumberFormatter</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
